<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sl" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@page import="com.solution.common.config.PublicConfig"%>
<%@page import="com.solution.admin.home.constants.IndexConstants"%>
<%
	String basePath = PublicConfig.ROOT_PATH;
	String wxRootUrl = PublicConfig.WX_ROOT_URL;
	String imgRootURL = PublicConfig.IMG_ROOT_URL;
	String ossImgZoomWX = PublicConfig.OSS_IMG_ZOOM_WX;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>商品详情</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/statics_wx/css/style.css?v=20180111">
<link rel="stylesheet" type="text/css" href="<%=basePath%>/statics_wx/css/idangerous.swiper.css">
<script type="text/javascript" src="<%=basePath%>/statics_wx/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/statics_wx/js/idangerous.swiper-2.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/statics_wx/js/custom.js"></script>
<script type="text/javascript" src="<%=basePath%>/statics/plugins/layer/layer.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="<%=basePath%>/statics_wx/js/js.js"></script>
<style type="text/css">
	table {
		margin-top:10px;
	    margin-bottom: 10px;
	    border-collapse: collapse;
	    display: table;
	}
	td, th {
	    padding: 5px 2px;
	    border: 1px solid #DDD;
	}
	.prd_intro1 img {
		max-width: 100%;
	}

	.box4_2 div img.current{
		border: 1px solid #e52244;
	}
	.pagination{top:auto;bottom:0.1rem;}
	.overlay {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.5);
		z-index: 100;
	}
	.share_box img {
		width: 100%;
	}
</style>
<script>
	//系统域名 
	var rootPath = '<%=basePath%>';
	var wxRootUrl = '<%=wxRootUrl%>';
	// 系统上传文件展示域名
	var imgRootURL = '<%=imgRootURL%>';
	$(function(){
		$('.detail_bottom ul li a.buybtn,.buy_box .hd span a').click(function(){
			$("#buy_box").toggle();
		});
		$('#backtop').click(function(){
		      $('body,html').animate({scrollTop: 0}, 1000);
		});
		$("#shareLi,#share_box").click(function(){
			$("#share_box").toggle();
		});
	 	$(window).scroll(function(){$scrollTo = $(window).scrollTop();
	    	if( $scrollTo > 100 ){
	        	$('#backtop').show();
	      	}else{
	        	$('#backtop').hide();
	      	}
	    }).trigger('scroll');
		jQuery('.prd_nav ul li').click(function() { TabSelect(".prd_nav ul li", "div.myintro", "current", jQuery(this)) });
		jQuery('.prd_nav ul li').eq(0).trigger("click");
		$('.favs').click(function(){
			$(".favs").toggleClass('current');
		});
		
		
		// 弹出临时调价窗口
		$("#spec_selector_product_price").click(function(){
			var adjust_price_auth = $("#adjust_price_auth").val();
			if(adjust_price_auth == 1){
				$("#adjust_price_box").toggle();
			}
		});
		
		// 确认价格修改
		$("#btn_confirm_adjust_price").click(function(){
			
			if($.trim($("#adjust_price_result").val()).length == 0){
				layer.msg("请输入展示价格");
				return false;
			}
			var tmp_price = parseFloat($("#adjust_price_result").val());
			var tmp_min_product_price = parseFloat($("#tmp_min_product_price").val());
			if(tmp_min_product_price > tmp_price){
				layer.msg("展示价格不能低于商品实际价格",{time:1000});
				return false;
			}
			$("#spec_selector_product_price").html("￥<em>"+numberInteger(tmp_price)+"</em>"+numberDecimal(tmp_price));
			$("#adjust_price_box").toggle();
		});
		
		// 取消价格修改
		$("#btn_cancel_adjust_price").click(function(){
			$("#adjust_price_result").val("");
			$("#adjust_price_box").toggle();
		});
		
	
		// 商品规格项的选中
		$('.good_sxlist ul li label').click(function(){
			if($(this).hasClass('checked')){
				$(this).addClass('checked');
			}else{
				$(this).addClass('checked');
				$(this).parent().siblings().find('label').removeClass('checked');
			}
			var spec_price = 0;
			$('.good_sxlist ul li label.checked').each(function(){
				spec_price = spec_price + parseFloat($(this).parent().attr("spec_price"));
			});
			var last_price = spec_price + parseFloat($("#main_produt_price").val());
			// $("#spec_selector_product_price").text(numberRand2(last_price));
			var tmp_price = numberRand2(last_price);
			$("#spec_selector_product_price").html("￥<em>"+numberInteger(tmp_price)+"</em>"+numberDecimal(tmp_price));
		});
	
		$('.cx_btn,#cx_box .bottom p .inputbtn1').click(function(){
			$('#cx_box').toggle();
		});
		
		// 0 立即购买  1 添加购物车
		var buy_type = 0;
		
		// 立即购买
		$("#btn_buy_now").click(function(){
			// buy_type = 0;
			// $('#goods_editbox').toggle();
			
			var buy_num = $("#buy_num").val();
			if(!buy_num || buy_num == 0){
				layer.msg('请选择购买数量',{time:1000});
				return false;
			}
			
			// 规格项选择
			var flag = true;
			var spec = [];
			$("div[name='spec_list']").each(function(){
				var spec_name= $(this).find("h3").text();
				var select_li = $(this).next("div.bd").find("label.checked");
				var selected_num = select_li.length;
				if(selected_num == 0){
					layer.msg('请选择'+spec_name,{time:2000});
					flag = false;
				}else{
					select_li.each(function(){
						spec.push({id:$(this).attr("spec_id"),specName:spec_name,specValue:$(this).text()});
					});
				}
			});
			
			if(!flag){
				return false;
			}
			
			// 立即购买
			var url = rootPath + "/wx/shoppingcart/directAdd";
			var form = $('<form></form>');
			form.attr('action', url);
			form.attr('method', 'post');
			form.attr('target', '_self');
			form.appendTo("body");
			form.append($("<input type='hidden' name='addFlag' value='1'/>"));
			form.append($("<input type='hidden' name='directBuy' value='1'/>"));
			form.append($("<input type='hidden' name='productId' value='" + $("#product_id").val() + "'/>"));
			form.append($("<input type='hidden' name='specListJson' value='" + JSON.stringify(spec) + "'/>"));
			form.append($("<input type='hidden' name='buyNum' value='"+buy_num+"'/>"));
			form.submit();
		});

		// 添加到购物车
		$("#btn_add_shoppingcart").click(function() {
			// buy_type = 1;
			// $('#goods_editbox').toggle();
			
			var buy_num = $("#buy_num").val();
			if(!buy_num || buy_num == 0){
				layer.msg('请选择购买数量',{time:1000});
				return false;
			}
			
			// 规格项选择
			var flag = true;
			var spec = [];
			$("div[name='spec_list']").each(function(){
				var spec_name= $(this).find("h3").text();
				var select_li = $(this).next("div.bd").find("label.checked");
				var selected_num = select_li.length;
				if(selected_num == 0){
					layer.msg('请选择'+spec_name,{time:2000});
					flag = false;
				}else{
					select_li.each(function(){
						spec.push({id:$(this).attr("spec_id"),specName:spec_name,specValue:$(this).text()});
					});
				}
			});
			
			if(!flag){
				return false;
			}
			
			// 添加购物车
			var url = rootPath + "/wx/shoppingcart/add";
			var params = {
				productId : $("#product_id").val(),
				buyNum : buy_num,
				addFlag : 1,
				specListJson : JSON.stringify(spec)
			};
			$.ajax({
				type : "post",
				url : url,
				data : params,
				datatype : "json",
				success : function(json) {
					if (json.resultCode == '1') {
						layer.msg('加入购物车成功', {
							time : 1000
						});
						$('#goods_editbox').toggle();
						showCartItemCount();
					}
				},
				error : function() {
					layer.msg('暂时无法加入购物车', {
						time : 1000
					});
				}
			});
		});

		// 已选好规格 项，确认购买
		$("#btn_confirm_buy").click(function(){
			var buy_num = $("#buy_num").val();
			if(!buy_num || buy_num == 0){
				layer.msg('请选择购买数量',{time:1000});
				return false;
			}
			
			// 规格项选择
			var flag = true;
			var spec = [];
			$("div[name='spec_list']").each(function(){
				var spec_name= $(this).find("h3").text();
				var select_li = $(this).next("div.bd").find("label.checked");
				var selected_num = select_li.length;
				if(selected_num == 0){
					layer.msg('请选择'+spec_name,{time:2000});
					flag = false;
				}else{
					select_li.each(function(){
						spec.push({id:$(this).attr("spec_id"),specName:spec_name,specValue:$(this).text()});
					});
				}
			});
			
			if(!flag){
				return false;
			}
			
			if(buy_type  == 0){
				// 立即购买
				var url = rootPath + "/wx/shoppingcart/directAdd";
				var form = $('<form></form>');
			    form.attr('action', url);
			    form.attr('method', 'post');
			    form.attr('target', '_self');
			    form.appendTo("body");
			    form.append($("<input type='hidden' name='addFlag' value='1'/>"));
			    form.append($("<input type='hidden' name='directBuy' value='1'/>"));
			    form.append($("<input type='hidden' name='productId' value='"+$("#product_id").val()+"'/>"));
			    form.append($("<input type='hidden' name='specListJson' value='"+JSON.stringify(spec)+"'/>"));
			    form.append($("<input type='hidden' name='buyNum' value='"+buy_num+"'/>"));
			    form.submit();
			}else{
				// 添加购物车
				var url = rootPath + "/wx/shoppingcart/add";
				var params = {
					productId : $("#product_id").val(),
					buyNum : buy_num,
					addFlag : 1,
					specListJson:JSON.stringify(spec)
				};
				$.ajax({
					type : "post",
					url : url,
					data : params,
					datatype : "json",
					success : function(json) {
						if (json.resultCode == '1') {
							layer.msg('加入购物车成功',{time:1000});
							$('#goods_editbox').toggle();
							showCartItemCount();
						}
					},
					error : function() {
						layer.msg('暂时无法加入购物车',{time:1000});
					}
				});
			}
			
		});
		

		// 关闭商品规格项选择弹层
		$("#btn_close_product_spec").click(function() {
			$("#goods_editbox").toggle();
		});

		// 查询购物车数量
		function showCartItemCount() {
			url = rootPath + "/wx/shoppingcart/getShoppingcarCount";
			$.ajax({
				type : 'POST',
				url : url,
				async : true,
				data : {},
				dataType : 'json',
				success : function(json) {
					if (json.resultCode == 1) {
						$("#item_count").text(parseInt(json.count) > 99 ? "99+" : json.count);
						//doSetShopCount(json.count);
					}
				}
			})
		}
		showCartItemCount();
		//隐藏用户名
		$(".username").each(function(){
			var userName = hideUserName($(this).text());
			$(this).html(userName);
		});

		var uuid = $("#uuid").val();
		var productId = $("#product_id").val();
		$.ajax({
			type : 'POST',
			url : rootPath + "/home/isLogin",
			async : true,
			dataType : 'json',
			success : function(json) {
				if (json.code == '1') {
					//登录用户分享自己的链接
					var linkUrl = wxRootUrl + "/wx/share/detail?uuid="+uuid;
					$("#shareLinkUrl").val(linkUrl);
				} else {
					//未登录用户分享本页面授权跳转链接(不填写默认分享本页)
					$("#shareLinkUrl").val("");
				}
			}
		});
		
		//微信接口调用参数
		wx.config({
			debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			appId : $('#appId').val(), // 必填，公众号的唯一标识
			timestamp : $('#timestamp').val(), // 必填，生成签名的时间戳
			nonceStr : $('#nonceStr').val(), // 必填，生成签名的随机串
			signature : $('#signature').val(),// 必填，签名
			jsApiList : [ 'onMenuShareTimeline', 'onMenuShareAppMessage' ] // 必填，需要使用的JS接口列表，所有JS接口列表
		});
		wx.ready(function(){
			wx.checkJsApi({
				jsApiList: [
				            'onMenuShareTimeline',
				            'onMenuShareAppMessage'
				            ]
			});

			//分享朋友
			var productId = $("#product_id").val();
			var productImage = $("#product_image").val();
			var productName = $("#product_name").val();
			var productTitle = $("#product_title").val();
			var linkUrl = $("#shareLinkUrl").val();
			wx.onMenuShareAppMessage({
				title: productName, // 分享标题
				desc: productTitle, // 分享描述
				link: linkUrl, // 分享链接，该链接域名必须与当前企业的可信域名一致
				imgUrl: productImage, // 分享图标
				success: function () {
					// 用户确认分享后执行的回调函数
					shareNotify(uuid, productId);
				},
				cancel: function () {
					// 用户取消分享后执行的回调函数
					$('#share_box').hide();
				},
				fail: function (res) {
					alert('wx.onMenuShareAppMessage:fail: '+JSON.stringify(res));
				}
			});

			//分享朋友圈
			wx.onMenuShareTimeline({
				title: productName, // 分享标题
				link: linkUrl, // 分享链接，该链接域名必须与当前企业的可信域名一致
				imgUrl: productImage, // 分享图标
				success: function () {
					// 用户确认分享后执行的回调函数
					shareNotify(uuid, productId);
				},
				cancel: function () {
					// 用户取消分享后执行的回调函数
					$('#share_box').hide();
				},
				fail: function (res) {
					alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
				}
			});
		});
		wx.error(function(res){
//			alert(JSON.stringify(res));
		});
		
	});

	//分享成功后回调
	function shareNotify(uuid, productId){
		$.ajax({
			type : 'POST',
			url : rootPath + "/home/isLogin",
			async : true,
			dataType : 'json',
			success : function(json) {
				if (json.code == '1') {
					//登录用户才回调创建新分享记录
					$.ajax({
						type:"post",
						url:rootPath+"/wx/share/doShareInfoShared",
						data:{uuid: uuid, productId: productId},
						datatype: "json",
						success:function(json){
							if (json.resultCode == "1") {
								console.log(json.resultMsg);
							} else {
								console.log(json.resultMsg);
							}
						},
						error: function(json){
							console.log(json.resultMsg);
						}
					});
				}
			}
		});
	}

	jQuery('#duice').click(function() {
		jQuery('.wthpop').show();
	})
	jQuery('.wthpop>p>span').click(function() {
		jQuery('.wthpop').hide()
	})

	//tab function
	function TabSelect(tab, con, addClass, obj) {
		var jQuery_self = obj;
		var jQuery_nav = jQuery(tab);

		jQuery_nav.removeClass(addClass), jQuery_self.addClass(addClass);

		var jQuery_index = jQuery_nav.index(jQuery_self);
		var jQuery_con = jQuery(con);
		jQuery_con.hide(), jQuery_con.eq(jQuery_index).show();
	}
	//编辑购物车数量
	function editShopcartNum(_this) {
		var $this = $(_this);
		var buy_num = $("#buy_num").val() || '1';
		if (isNaN(buy_num) || !(/^\d+$/.test(buy_num))) {
			layer.msg('只能输入整数', {
				time : 1000
			});
			return false;
		}
		var int_buy_num = parseInt(buy_num);
		if (int_buy_num < 1) {
			$("#buy_num").val("1");
			return;
		}
		if ($this.attr("id") == 'subtract_num') { // + 
			if (int_buy_num > 1) {
				$("#buy_num").val(int_buy_num - 1);
			}
			if (int_buy_num == 1) {
				$this.removeClass().addClass("icon_jian_gray");
			}
		} else { // -
			$("#buy_num").val(int_buy_num + 1);
			if ($("#subtract_num").attr('class') == "icon_jian_gray") {
				$("#subtract_num").removeClass().addClass("icon_jian");
			}
		}

	}
</script>
</head>
<body style="background: #f5f5f5">
	<c:set var="rootPath" value="<%=basePath %>"></c:set>
	<c:set var="imgRootURL" value="<%=imgRootURL %>"></c:set>
	<c:set var="ossImgZoomWX" value="<%=ossImgZoomWX %>"></c:set>
	<input type="hidden" id="appId" value="${appId }"/>
	<input type="hidden" id="timestamp" value="${timestamp }"/>
	<input type="hidden" id="nonceStr" value="${nonceStr }"/>
	<input type="hidden" id="signature" value="${signature }"/>
	<input type="hidden" id="uuid" value="${uuid }"/>
	<input type="hidden" id="shareLinkUrl" value=""/>
	<a href="javascript:void(0)" id="backtop"></a>
	<input type="hidden"  id="main_produt_price"  value="${mainProductPrice }"/>
	<input type="hidden"  id="adjust_price_auth" value="${adjustPriceAuth }"/>
	
	<div class="overlay" id="share_box" style="display: none">
		<div class="share_box">
			<img src="<%=basePath%>/statics_wx/images/share_pic.png" />
		</div>
	</div>
	
	<!-- 调价窗口 -->
	<div class="overlay" id="adjust_price_box" style="display:none;">
		<div class="msg_box" style="height:3.6rem;">
			<div class="bd" style="border-bottom:0.02rem solid #e8e8e8">
				<p style="padding:0.2rem 0;text-align:left;padding-left:0.3rem;">修改展示价格</p>
			</div>
	        <div class="bd1" style="padding-top:0.3rem;margin:0 0.3rem;text-align:center;">
	        	<p><input id="adjust_price_result" type="text" class="inputstyle1" value="" placeholder="请输入展示价格" style="height:0.6rem;line-height:0.6rem;border: .02rem solid #e8e8e8;font-size:0.28rem;text-indent:0.2rem;border-radius: .05rem;width:100%;" /></p>
	        	<p style="margin-top:0.15rem;text-align:left;"><span style="font-size:12px;color:red;">用于修改展示价，不影响最终成交价</span></p>
	        </div>
			<div class="bottom" >
				<ul>
					<li>
						<a id="btn_cancel_adjust_price" href="javascript:void(0)">取消</a><i></i>
					</li>
					<li>
						<a id="btn_confirm_adjust_price" href="javascript:void(0)">确认</a>
					</li>
				</ul>
			</div>
		</div>
	</div>
	
	
	<!--
	<div class="overlay" id="goods_editbox" style="display: none">
		<div class="goods_editbox">
			<a id="btn_close_product_spec" href="javascript:void(0)" class="icon_close"></a>
			<div class="goods_editbox_con">
				<div class="good_info1">
					<div class="pic">
						<img src="${imgRootURL}/${productDetailMap['product_info'].productImgPath }" />
					</div>
					<div class="item-info">
						<h2>${productDetailMap['product_info'].productName}</h2>
						<h3>
							￥<em id="spec_selector_product_price"><fmt:formatNumber type="number" value="${productPrice}" pattern="0.00" /></em>
						</h3>
					</div>
				</div>
				
				<div class="good_info2">
					<c:forEach items="${productDetailMap['product_spec']}" var="productSpec">
						<div name="spec_list" class="hd">
							<h3>${productSpec.specName }</h3>
						</div>
						<div class="bd">
							<div class="good_sxlist">
								<ul>
									<c:forEach items="${productSpec.productSpecList}" var="spec" varStatus="ind">
										<li spec_price="${spec.specPrice}"><label ${ind.index == 0 ? "class='checked'" : "" } spec_id="${spec.id}">${spec.specValue}</label></li>
									</c:forEach>
								</ul>
							</div>
						</div>
					</c:forEach>
				</div>
				<div class="good_info3">
					<strong>数量</strong>
					<div class="txt1">
						<b> <a href="javascript:void(0)" class="icon_jian_gray" id="subtract_num" onclick="editShopcartNum(this)"></a><span> 
							<input id="buy_num" type="text" value="1"></span> 
							<a href="javascript:void(0)" class="icon_jia" id="add_num" onclick="editShopcartNum(this)"></a>
						</b>
					</div>
				</div>
			</div>
			<div class="bottom">
				<p>
					<input type="button" id="btn_confirm_buy" class="inputbtn1" value="确定" />
				</p>
			</div>
		</div>
	</div>
	-->
	
	<div class="overlay" id="cx_box" style="display: none">
		<div class="zp_box">
			<div class="hd">
				<h3>促销</h3>
			</div>
			<div class="bd">
				<div class="cx_list">
					<ul>
						<c:forEach items="${promotionShowList}" var="promotion">
							<li><em>${promotion.promotionTypeName}</em><p>${promotion.promotionIntro}</p></li>		
						</c:forEach>
					</ul>
				</div>
			</div>
			<div class="bottom">
				<p>
					<input id="btn_confirm_promotion" type="button" class="inputbtn1" value="确定" />
				</p>
			</div>
		</div>
	</div>
	
	<div class="body">
		<div class="header">
			<div class="index_header4">
				<div class="icon_back2">
					<a href="#"></a>
				</div>
			</div>
		</div>
		<div class="content">
			<div class="banner banners">
				<div class="swiper-container banner2">
					<div class="swiper-wrapper">
						<c:forEach items="${productDetailMap['product_image']}" var="image">
							<div class="swiper-slide">
								<img src="${imgRootURL}/${image.imagePath}" />
							</div>
							<c:if test="${image.imageType eq 1}">
								<input type="hidden" id="product_image" value="${imgRootURL}${image.imagePath}${ossImgZoomWX }"/>
							</c:if>
						</c:forEach>
					</div>
				</div>
				<div class="pagination page2"></div>
			</div>

			<div class="detail_infos1">
				<div class="detail_infos1_con">
					<div class="detail_infos11">
						
						<%--是否拥有规格项 --%>
						<input type="hidden" id="has_spec" value="${hasSpec}"/>
						<input type="hidden" id="product_id" value="${productDetailMap['product_info'].id}"/>
						<input type="hidden" id="product_name" value="${productDetailMap['product_info'].productName}"/>
						<input type="hidden" id="product_title" value="${productDetailMap['product_info'].productTitle}"/>
						<a href="javascript:void(0)" class="good_btn">
							<h1>
							${productDetailMap['product_info'].productName}
							<c:if test="${productDetailMap['product_info'].productStatus eq '2'}">
							<span class="label label-warning" >预售中</span>
							</c:if>
							<c:if test="${productDetailMap['product_info'].productStatus eq '3'}">
							<span class="label label-danger" >已售罄</span>
							</c:if>
							</h1>
						</a>
						<h3 id="spec_selector_product_price">
							￥<em><sl:nformat num="${productPrice}" format=".00" type="2"/></em>
								  <sl:nformat num="${productPrice}" format=".00" type="3"/>
						</h3>
						<input id="tmp_min_product_price" type="hidden" value="${productPrice}"/>
					</div>
					<c:if test="${promotionShowList.size() > 0 }">
					<div class="detail_infos12">
						<dl>
							<dt>
								<i>促销</i>
								<div class="cx_part">
									<ul>
										<c:forEach items="${promotionShowList}" var="promotion">
											<li><a href="javascript:void(0)" class="cx_btn"> <strong>${promotion.promotionTypeName}</strong>
													<p>
													<span>${promotion.promotionIntro}</span> <em></em>
													</p>
												</a>
											</li>
										</c:forEach>
									</ul>
								</div>
							</dt>
						</dl>
					</div>
					</c:if>
				</div>
			</div>
			
			<%--规格项和数量选择 --%>
			<div class="goods_editbox_con" style="background:#fff;width:100%;padding:0;display:inline-block;border-top:0.08rem solid #efefef">
				<div class="good_info2" style="padding:0 0.2rem;max-height:inherit">
					<c:forEach items="${productDetailMap['product_spec']}" var="productSpec">
						<div name="spec_list" class="hd">
							<h3>${productSpec.specName }</h3>
						</div>
						<div class="bd">
							<div class="good_sxlist">
								<ul>
									<c:forEach items="${productSpec.productSpecList}" var="spec" varStatus="ind">
										<li spec_price="${spec.specPrice}"><label ${ind.index == 0 ? "class='checked'" : "" } spec_id="${spec.id}">${spec.specValue}</label></li>
									</c:forEach>
								</ul>
							</div>
						</div>
					</c:forEach>
				</div>
				<div class="good_info3" style="border-top:0.02rem solid #efefef;padding-top:0.2rem">
					<strong style="left:0.2rem;top:0.2rem">数量</strong>
					<div class="txt1" style="margin-right:0.2rem">
						<b> <a href="javascript:void(0)" class="icon_jian_gray" id="subtract_num" onclick="editShopcartNum(this)"></a><span> 
							<input id="buy_num" type="text" value="1"></span> 
							<a href="javascript:void(0)" class="icon_jia" id="add_num" onclick="editShopcartNum(this)"></a>
						</b>
					</div>
				</div>
			</div>
			
			
			<div class="prd_nav">
				<ul>
					<li tag="productIntro" class="current"><a href="javascript:void(0)">商品介绍<i></i></a>
					</li>
					<li tag="productProperty"><a href="javascript:void(0)">属性参数<i></i></a></li>
					<li tag="evaluation"><a href="javascript:void(0)">评价（${evaluationPage.totalCount }）<i></i></a></li>
				</ul>
			</div>
			<div class="prd_intro">
				<div class="prd_intro_con">
					<div class="myintro">
						<div class="prd_intro1">
							${productDetailMap['product_info'].productIntro }
						</div>
					</div>
					<div class="myintro">
						<div class="prd_intro1">
							<div class="prd_intro11">
								<table>
									<c:forEach items="${productDetailMap['product_property'] }" var="property">
										<tr>
											<td>${property.propertyName}</td>
											<td>${property.propertyValue }</td>
										</tr>
									</c:forEach>
								</table>
							</div>
						</div>
					</div>
					<div class="myintro">
						<div class="prd_intro2">
							<div class="comment_list">
								<input id="numPerPage" type="hidden" value="${evaluationPage.numPerPage }"/>
								<input id="currentPage" type="hidden" value="${evaluationPage.currentPage }"/>
								<input id="pageCount" type="hidden" value="${evaluationPage.pageCount }"/>
								<ul id="comment_ul">
									<c:forEach items="${evaluationPage.recordList }" var="record" varStatus="i">
										<li>
											<div class="box4">
												<div class="pic">
													<img src="${imgRootURL}/${record.headImage }?x-oss-process=image/resize,h_100/format,png" onerror="this.src='${rootPath }/statics_wx/images/user_img2.png'"/>
												</div>
												<div class="item-info">
													<div class="box4_1">
														<div class="left">
															<h2 class="username">${record.userName }</h2>
															<h3>
																<span class="bg1">
																	<span class="bg2" style="width: ${record.score * 20 }%"></span>
																</span>
															</h3>
														</div>
														<div class="right">
															<p>${record.createTimeStr }</p>
														</div>
													</div>
													<div class="box4_2">
														<p>${record.content }</p>
													</div>
													<c:if test="${fn:length(record.filePathList) > 0 }">
													<div class="box4_2">
														<p>
															<c:forEach items="${record.filePathList }" var="filePath" varStatus="i2">
															<div style="float:left; margin-left: 5px;">
																<img class="smallpics" data-src="${imgRootURL}/${filePath}" src="${imgRootURL}/${filePath}?x-oss-process=image/resize,m_pad,h_50,w_50,color_000000/format,png" alt="" onclick="imageView(this);"/>
															</div>
															</c:forEach>
														</p>
													</div>
													</c:if>
													<div class="box4_3">
														<dl>
															<dt>${record.productName }</dt>
															<%-- <dt>购买日期：${record.createTimeStr }</dt> --%>
														</dl>
													</div>
												</div>
											</div>
										</li>
									</c:forEach>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="height3"></div>

		<div class="detail_bottom">
			<ul>
                <c:choose>
                    <c:when test="${not empty favoriteId}">
                        <li class="favs">
                            <a href="#" id="scLink" onclick="javascript: doDelFavorite('${favoriteId}');">
                                <p>
                                    <i id="scLi" class="iconsc"></i><em id="scEmTxt">取消收藏</em>
                                </p>
                        </a> <u></u></li>
                    </c:when>
                    <c:otherwise>
                        <li class="favs">
                            <a href="#" id="scLink" onclick="javascript: doAddFavorite();">
                                <p>
                                    <i id="scLi" class="icon1"></i><em id="scEmTxt">收藏</em>
                                </p>
                        </a> <u></u></li>
                    </c:otherwise>
                </c:choose>
                
                <li class="favs" id="shareLi">
					<a href="javascript:void(0);">
						<p>
							<i class="icon3"></i>
							<em>分享</em>
						</p>
					</a>
					<u></u>
				</li>
				<li><a href="${rootPath}/wx/shoppingcart/list">
						<p>
							<i class="icon2"></i><s id="item_count">0</s> <em>购物车</em>
						</p>
				</a> <u></u>
				</li>
				
				<c:choose>
					<c:when test="${productDetailMap['product_info'].productStatus eq '1' || productDetailMap['product_info'].productStatus eq '2'  }">
						<li>
							<a href="javascript:void(0)" id="btn_buy_now" class="buybtn"><span>立即购买</span></a>
						</li>
						<li>
							<a href="javascript:void(0)" id="btn_add_shoppingcart" class="buybtn add_cartbtn"><span>加入购物车</span></a>
						</li>
					</c:when>
					<c:otherwise>
						<li style="width: 60%;">
							<a href="javascript:void(0)" class="buybtn" style="background-color: #e8e8e8;"><span style="color: #000">已售罄</span></a>
						</li>
					</c:otherwise>
				</c:choose>
			</ul>
		</div>
	</div>

	<script type="text/javascript">
		var mySwiper1 = new Swiper('.banner2', {
			pagination: '.page2',
			loop: true,
			autoplay: 5000,
			paginationClickable: true
		});
		
		/**
		 * 加入收藏
		 */
		function doAddFavorite() {
		    var productId =  $("#product_id").val();
		    $.ajax({
				type : "post",
				url : rootPath + '/wx/favorite/addFavorite',
				data : {
				    productId : productId
				},
				datatype : "json",
				success : function(json) {
					if (json.code == '1') {
					    var favoriteId = json.data;
						layer.msg(json.msg,{time:3000});
						$("#scLink").removeAttr('onclick');
						$("#scLink").attr("onclick","doDelFavorite('"+favoriteId+"');");
						$("#scLi").removeClass('icon1');
						$("#scLi").addClass('iconsc');
						$("#scEmTxt").html('取消收藏');
					} else {
						layer.msg(json.msg,{time:3000});
					}
				},
				error : function() {
					layer.msg('暂时无法加入收藏',{time:1000});
				}
			});
		}
		/**
		 * 取消收藏
		 */
		function doDelFavorite(favoriteId) {
		    $.ajax({
				type : "post",
				url : rootPath + '/wx/favorite/doDelFavorite',
				data : {
				    idArrStr : favoriteId
				},
				datatype : "json",
				success : function(json) {
					if (json.code == '1') {
						layer.msg(json.msg,{time:3000});
						$("#scLink").removeAttr('onclick');
						$("#scLink").attr("onclick","doAddFavorite();");
						$("#scLi").removeClass('iconsc');
						$("#scLi").addClass('icon1');
						$("#scEmTxt").html('收藏');
					} else {
						layer.msg(json.msg,{time:3000});
					}
				},
				error : function() {
					layer.msg('暂时无法取消收藏',{time:1000});
				}
			});
		}
		
		/**
		 * 上拉加载
		 */
		 $(window).on('scroll',function(){
			 if($(window).scrollTop()>=$(document).height()-$(window).height()){
				var tag = $("li.current").attr("tag");
				if (tag == "evaluation") {
				    var numPerPage = $("#numPerPage").val();
				    var currentPage = $("#currentPage").val();
				    var pageCount = $("#pageCount").val();
				    var productId =  $("#product_id").val();
				    if(currentPage >= pageCount){
			    		layer.msg('已经到底了',{time:500});
			    		return false;
			    	}
					$.ajax({
						type : "post",
						url : rootPath + "/wx/product/queryProductEvaluation",
						data : {productId: productId,tmpCurrentPage: Number(currentPage)+1, tmpNumPerPage: numPerPage},
						datatype : "json",
						success : function(jsonObject) {
						    var numPerPage = $("#numPerPage").val(jsonObject.evaluationPage.numPerPage);
						    var currentPage = $("#currentPage").val(jsonObject.evaluationPage.currentPage);
						    var pageCount = $("#pageCount").val(jsonObject.evaluationPage.pageCount);
							$.each(jsonObject.evaluationPage.recordList, function(i,record){
								var li = "<li>" +
								"<div class='box4'>" +
									"<div class='pic'>" +
										"<img src='"+imgRootURL+"/"+record.headImage+"?x-oss-process=image/resize,h_100/format,png' onerror='this.src=\""+rootPath+"/statics_wx/images/user_img2.png\"'/>" +
									"</div>" +
									"<div class='item-info'>" +
										"<div class='box4_1'>" +
											"<div class='left'>" +
												"<h2 class='username'>"+hideUserName(record.userName)+"</h2>" +
												"<h3>" +
													"<span class='bg1'>" +
														"<span class='bg2' style='width: "+(record.score*20)+"%'></span>" +
													"</span>" +
												"</h3>" +
											"</div>" +
											"<div class='right'>" +
												"<p>"+record.createTimeStr+"</p>" +
											"</div>" +
										"</div>";
								if (record.filePathList.length > 0){
									li += "<div class='box4_2'>" + 
											"<p>";
								}
								$.each(record.filePathList, function(i, filePath){
									li += "<div style='float:left; margin-left: 5px;'>" +
											"<img class='smallpics' data-src='"+imgRootURL + filePath+"' src='"+imgRootURL + filePath+"?x-oss-process=image/resize,m_pad,h_50,w_50,color_000000/format,png' alt='' onclick='imageView(this);'/>" +
										"</div>";
								});
								if (record.filePathList.length > 0){
									li += "</p></div>";
								}
								li +=	"<div class='box4_2'>" +
											"<p>"+record.content+"</p>" +
										"</div>" +
										"<div class='box4_3'>" +
											"<dl>" +
												"<dt>"+record.productName+"</dt>" +
											"</dl>" +
										"</div>" +
									"</div>" +
								"</div></li>";
								$("#comment_ul").append(li);
							});
						},
						error : function() {
							layer.msg('查询商品失败',{time:1000});
						}
					});
				}
			 }
		 });
		//隐藏用户名
		 function hideUserName(userName){
		 	var hideName = "";
		 	if (userName.length < 3) {
		 		hideName = userName.substr(0,1) + "****";
		 	} else {
		 		hideName = userName.substr(0,1) + "****";
		 	}
		 	return hideName;
		 }

		//微信图片预览
		function imageView(this_) {
			var src = $(this_).attr("data-src");
			var srcPre = src + '?x-oss-process=image/resize,m_pad,h_60,w_60';
			/**
			wx.previewImage({
				current : srcPre, // 当前显示图片的http链接  
				urls : [ src ]
				// 需要预览的图片http链接列表  
			})
			*/
			WeixinJSBridge.invoke('imagePreview', {  
				'current': srcPre,  
				'urls': [src]
			});  
		}
	</script>
</body>
</html>